package reflect;

import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;


public class Reflect {


	public static void main(String[] args) throws SecurityException, NoSuchMethodException, IllegalArgumentException, InvocationTargetException {
		try {
			Class clazz = Class.forName("java.lang.String");
			try {
				Constructor test = clazz.getConstructor(String.class);
				@SuppressWarnings("unused")
				Object a = test.newInstance("test");
			} catch (InstantiationException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (IllegalAccessException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			Method[] ms = clazz.getMethods();
			Field[] fs = clazz.getFields();
			for(Field f:fs){
				System.out.println(f.getName());
			}
			
			for(Method m:ms){
				System.out.println(m.getName());
			}
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

}
